package cn.ccccltd.waf.id_generator.config.sql;

import org.apache.ibatis.jdbc.SQL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.ccccltd.waf.id_generator.config.sql.param.QueryParams;

public class CommonSqlProvider extends SqlProvider{
	
	private static final Logger log = LoggerFactory.getLogger(CommonSqlProvider.class);
	
	public static String getByPage(final QueryParams queryParams,Object obj) {
		
		SQL sql = new SQL();
		
		processSelectByPageSql(sql, obj.getClass(), queryParams);

		return sql.toString();
		
	}
	
	public static String delete(Object obj) {
		
		SQL sql = new SQL();
		
		processDeleteSql(sql, obj);
		
		String deleteSql = sql.toString();
		
		log.info("delete sql语句 : " + deleteSql);
		
		return deleteSql;
		
	}
	
	public static String insert(Object obj) {
		
		SQL sql = new SQL();
		
		processInsertSql(sql, obj);
		
		String insertSql = sql.toString();
		
		log.info("insert sql语句 : " + insertSql);
		
		return insertSql;
		
	}
	
	public static String update(Object obj) {
		
		SQL sql = new SQL();
		
		processUpdateSql(sql, obj);
		
		String updateSql = sql.toString();
		
		log.info("update sql语句 : " + updateSql);
		
		return updateSql;
		
	}
	
	public static String get(Object obj) {
		
		SQL sql = new SQL();
		
		processGetSql(sql, obj);
		
		String getSql = sql.toString();
		
		log.info("get sql语句 : " + getSql);
		
		return getSql;
		
	}
	

}
